#include "TPM_HAL_GB.h"

uint8 u8TPM_CheckTOF (uint8 u8timer)
{
    if (u8timer == 1)
    {
        return TPM1SC_TOF;
    }
    else
    {
        return TPM2SC_TOF;
    }        
}

void vfnTPM_ClearTOF (uint8 u8timer)
{
    if (u8timer == 1)
    {
        TPM1SC_TOF = 0;
    }
    else
    {
        TPM2SC_TOF = 0;
    }
}

void vfnTPM_PrescalerSelect (uint8 u8timer, uint8 u8prescaler)
{
    if (u8timer == 1)
    {
        TPM1SC_PS = u8prescaler;
    }
    else
    {
        TPM2SC_PS = u8prescaler;
    }
}

void vfnTPM_SetModulo (uint8 u8timer, uint16 u16modulo)
{
    if (u8timer == 1)
    {
        TPM1MOD = u16modulo;
    }
    else
    {
        TPM2MOD = u16modulo;
    }    
}

void vfnTPM_ClockSelect (uint8 u8timer, uint8 u8clock)
{
    if (u8timer == 1)
    {
        TPM1SC_CLKSx = u8clock;
    }
    else
    {
        TPM2SC_CLKSx = u8clock;
    }    
}


uint8 u8TPM_GetTimerCounterL (uint8 u8timer)
{
	if (u8timer == 1)
    {
    	(void)TPM1CNTH;
        return TPM1CNTL;
    }
    else
    {
    	(void)TPM2CNTH;
        return TPM2CNTL;
    }  	
}

void vfnTPM_ClearCounter (uint8 u8timer)
{
	if (u8timer == 1)
    {
        TPM1CNTL = 0;
    }
    else
    {
        TPM2CNTL = 0;
    }	
}







